package pe.gob.onp.workflow.bean;

import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.List;

import javax.ejb.CreateException;

import pe.gob.onp.util.LazyLoadable;

import com.ejbs.ESGenerico;
import com.util.Factory;

public class LazyCliente implements LazyLoadable{

	private static final long serialVersionUID = 1676780956302516950L;
	private Long size;
	private ESGenerico ejb;

	public LazyCliente() throws RemoteException, CreateException{
		
	}
	
	public LazyCliente(ESGenerico ejb) throws RemoteException, CreateException{
		this.ejb = ejb;
	}

	public Long getSize() {
		return this.size;
	}

	public List getUpdatedList(int index, int pageSize) throws Exception {
		List lista = null;
		HashMap map = new HashMap();
		map.put("begin", new Integer(index));
		map.put("end", new Integer(index + pageSize));
		System.out.println("LazyCliente.getUpdatedList : index/ pageSize = " + index + "/" +  pageSize);
		try{
			lista = this.ejb.listar(map);
			System.out.println("> query retorna lista con " +lista.size() + " elementos");
		}catch(Exception e){
			throw e;
		}
		return lista;
	}

	public void setSize(Long size) {
		// TODO Auto-generated method stub
		this.size = size;
	}

}